package com.crmfront.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.crmfront.pojo.User;
import com.class1801.util.UrlUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {

    @RequestMapping("/userList")
    public String userList(Model model) {

        String url = "http://116.63.165.189:8066/user/userList" ;
        String params = "" ;

        String result = UrlUtils.sendGet(url, params) ;

        JSONArray array = JSON.parseArray(result) ;
        List<User> userList  = array.toJavaList(User.class) ;

        model.addAttribute("userList", userList) ;

        return "user/userList" ;
    }
}
